<div class="order-list-page" ng-if="pagedata.op == 'list'">
    <div class="fui-header">
		<div class="fui-header-left" ng-click="goback()">
            <a class="back"></a>
        </div>
		<div class="title">配送订单</div>
		<div class="fui-header-right"></div>
	</div>
	<div style="margin-top:58px"></div>
	<div id="tab" class="fui-tab fui-tab-danger">
        <a ng-class="{'external active':pagedata.status == 2}" href="javascript:" ng-click="access_json('list','status=2');pagedata.status =2">配送中</a>
        <a ng-class="{'external active':pagedata.status == 3}" href="javascript:" ng-click="access_json('list','status=3');pagedata.status =3">已完成</a>
		<a ng-class="{'external active':pagedata.status == 7}" href="javascript:" ng-click="access_json('list','status=7');pagedata.status =7">异常报备</a>
    </div>
	<div class='fui-content order-list' style="margin-top:4.4rem">
	<div class="fui-list-group order-item" ng-repeat="item in pagedata.list">
                <a class="fui-list external" style="padding: 0.42rem 0.5rem">
                    <div class="fui-list-inner">
                        <div class="subtitle"> 订单号: {{item.ordersn}}</div>
                    </div>
                    <div ng-show="item.status==2" class="row-remark text-cancel" style="width: 4rem; font-size: 0.65rem;text-align: right;">待配送</div>
                    <div ng-show="item.status==7" class="row-remark text-cancel" style="width: 4rem; font-size: 0.65rem;text-align: right;">异常报备</div>
					<div ng-show="item.status==3 || item.status==5" class="row-remark text-cancel" style="width: 4rem; font-size: 0.65rem;text-align: right;">已完成</div>
                    <div class="angle"></div>
                </a> 
                    <div class="fui-list" style="padding-bottom:0">
                        <a href="tel:{{item.store.tel || item.store.mobile}}" class="fui-list-angle">
                            <i class="icon jinyunicon icon-dianpu"></i> {{item.store.title || '配送门店'}}
							<div class="subtitle" style="line-height:1;font-size:0.6rem"><i class="icon icon-phone" style="font-size:0.6rem"></i> {{item.store.tel || item.store.mobile}}</div>
						</a>
						<div class="fui-list-inner" ng-click="pagedata.openLocation(item.store);">
							<span class="status noremark" style="font-size:0.55rem"><i class="icon icon-map" style="font-size:0.50rem"></i> <span style="color:#f60;">{{item.store.address || '无'}}</span></span>
						</div>
                    </div>
                    <div ng-repeat="g in item.goods" class="fui-list goods-list">
                            <div class="fui-list-media" style="">
                                <img class="" ng-src="{{tomedia(g.image) || '../core/resource/images/nopic.jpg'}}">
                            </div>
                            <div class="fui-list-inner">
                               <div class="text goodstitle towline">{{g.goods_title || '菜品名称'}}</div>
								<div class="text goodstitle">规格：{{g.optiontitle || '无'}}</div>
                            </div>
                            <div class="fui-list-angle" style="width:3rem">
                                ￥<span class="marketprice">{{g.totalprice}}</span></div>
                     </div>
					<div class="title" style="padding:0 0.5rem">
						<div><i class="icon icon-qitashouru" style="font-size: 0.65rem">支付方式：<span class="price red">{{pagedata.paytypes[item.paytype]}}</span> 状态：<span class="price red">{{item.ispay==1?'已支付':'未支付'}}</span></i></div>
						<div><i class="icon icon-trade" style="font-size: 0.65rem"> 配送费：<span class="price red">￥{{pagedata.pluginset.peisong_fee || 0}}.00</span></i></div>
						<div ng-if="item.addprice"><i class="icon icon-trade" style="font-size: 0.65rem"> 多退少补：<span class="price red">￥{{item.addprice || '0.00'}}</span></i> <div ng-if="item.addprice>0 && item.ispayadd!=1" class="btn btn-sm btn-success-o order-finish" style="border-radius: 1rem;padding:0 0.5rem" href="javascript:" ng-click="pagedata.showpayewm=true;pagedata.show_ewn(item.id);">补差价</div></div>
						<div><i class="icon icon-shijian" style="font-size: 0.65rem"> 配送时间：<span class="red">{{item.selfinfo.selftime}}</span></i></div>
						<div class="subtitle"><i class="icon icon-shijian" style="font-size: 0.65rem">下单时间：{{item.createtime}}</i></div>
						<div ng-if="item.paytime" class="subtitle"><i class="icon icon-shijian" style="font-size: 0.65rem">支付时间：{{item.paytime}}</i></div>
					</div>
					<div class="fui-list">
                        <div class="fui-list-inner">
							<div style="line-height:1.4;color:#999;font-size:0.65rem"><i class="icon icon-wo1"></i> 联系人： <span class="text-danger">{{item.order_out.name}}  </span>；  联系电话： <a href="tel:{{item.order_out.mobile}}" class="text-danger">{{item.order_out.mobile}}</a></div>
							<div style="line-height:1.4;color:#999;font-size:0.65rem"><i class="icon icon-ditu"></i>  配送地址： <span class="text-danger">{{item.order_out.pcd.city}} {{item.order_out.pcd.district}} {{item.order_out.pcd.street}} {{item.order_out.address}} </span> <a href="javascript:" ng-click="pagedata.openLocation(item.order_out);" class="btn btn-sm btn-danger-o" style="font-size:0.65rem;line-height: 1.5;"><i class="icon icon-lvyoutehui"></i>导航</a></div>
							<div style="line-height:1.4;color:#999;font-size:0.65rem"><i class="icon icon-liaotian"></i> 备注： <span class="text-danger">{{item.remark || '无'}}  </span></div>
						</div>
					</div>
					<div  class="fui-list-group-title lineblock opblock">
						<span class="t-r" ng-if="item.selfinfo.number2" ><i class="icon icon-peisong" style="font-size: 0.65rem"> 取货号：<span class="price bold">{{item.selfinfo.number2}}</span></i></span>
						<span ng-if="item.status==2" class="status noremark">
							<div class="btn btn-sm btn-success-o order-finish" href="javascript:" ng-click="pagedata.post.id=item.id;pagedata.changeshow=true">转单</div>
						</span>
						<span ng-if="item.status==2 && item.send_status==13" class="status noremark">
							<div class="btn btn-sm btn-danger-o order-finish" href="javascript:" ng-click="post({},'jieorder','id='+item.id)">确认接单</div>
						</span>
						<span ng-if="item.status==2 && item.send_status!=13" class="status noremark">
							<div class="btn btn-sm btn-danger-o order-finish" href="javascript:" ng-click="post({},'receive','id='+item.id)">确认收货</div>
						</span>
						<span ng-if="item.status==2 && item.send_status!=13" class="status noremark">
							<div class="btn btn-sm btn-success-o order-finish" href="javascript:" ng-click="pagedata.post.id=item.id;pagedata.showbaobei=true">异常报备</div>
						</span>
					</div>
        </div>
	</div>
	<div class="content-empty" ng-show="pagedata.order_list.length == 0 ">
		  <i class="icon jinyunicon icon-cry" style="width: 6rem;margin-bottom: 0.5rem;"></i><br/><p style="color: #999;font-size: .75rem">您暂时没有配送任务！</p>
	</div>
</div>
<div class="order-list-page" ng-if="pagedata.op == 'detail'">
    <div class="fui-header">
		<div class="fui-header-left" ng-click="goback()">
            <a class="back"></a>
        </div>
		<div class="title">订单详情</div>
		<div class="fui-header-right"></div>
	</div>
	<div class="fui-content member-page" style="top:0">
		<div class="fui-list-group merchgroup">
			<div class="fui-list jump">
                <a class="fui-list-media">
                    <img class="round" ng-src="{{pagedata.member.avatar || '../core/resource/images/nopic.jpg'}}" />
                </a>
                <div class="fui-list-inner">
					<div class="title" style="font-size:0.65rem">昵称：{{pagedata.member.nickname}}</div>
                </div>
                <a class="jump" href="javascript:;">
					
				</a>
            </div>
		</div>
		<div class="weui_cells">
			<div class="weui_cell">
					<div class="weui_cell_bd weui_cell_primary">
						<span>配送门店</span>
					</div>
					<div class="weui_cell_ft" ng-model="pagedata.post.serve_title">{{pagedata.store.title}}</div>
			</div>
			<div class="weui_cell">
					<div class="weui_cell_bd weui_cell_primary">
						<span>支付时间</span>
					</div>
					<div class="weui_cell_ft" ng-model="pagedata.post.time">{{pagedata.order.paytime}}</div>
			</div>
			<div class="weui_cell">
					<div class="weui_cell_bd weui_cell_primary">
						<span>用户姓名</span>
					</div>
					<div class="weui_cell_ft" ng-model="pagedata.post.address">{{pagedata.order.username}}</div>
			</div>
			<div class="weui_cell">
					<div class="weui_cell_bd weui_cell_primary">
						<span>联系电话</span>
					</div>
					<div class="weui_cell_ft" ng-model="pagedata.post.address">{{pagedata.order.mobile}}</div>
			</div>
			<div class="weui_cell">
					<div class="weui_cell_bd weui_cell_primary">
						<span>用户地址</span>
					</div>
					<div class="weui_cell_ft" ng-model="pagedata.post.address">{{pagedata.order.address}}</div>
			</div>
			<div class="weui_cell">
					<div class="weui_cell_bd weui_cell_primary">
						<span>备注</span>
					</div>
					<div class="weui_cell_ft" ng-model="pagedata.post.remark">{{pagedata.order.remark}}</div>
			</div>
			<div class="weui_cell">
					<div class="weui_cell_bd weui_cell_primary">
						<span>配送费用</span>
					</div>
					<div class="weui_cell_ft" ng-model="pagedata.post.package_price">{{pagedata.order.package.package_price}}元</div>
			</div>
			<div class="weui_cell">
					<div class="weui_cell_bd weui_cell_primary">
						<span>实际支付</span>
					</div>
					<div class="weui_cell_ft" ng-model="pagedata.post.package_price">{{pagedata.order.price}}元</div>
			</div>
		</div>
	</div>
</div>
<div class="fui-navbar">
	<a href="javascript:;" ng-click="access_json('jy_peimilk/peisong_order/')" class="nav-item" style="background:#00c568;color:#fff">立即抢单</a>
	<a href="javascript:;" ng-click="access_json('jy_peimilk/worker_order/')" class="nav-item" style="background:red;color:#fff">我的配送</a>
</div>
<div ng-if="pagedata.changeshow" class="popup">
	<div class="popup-body">
		<div class="popup-bottom">
			<i class="closed icon icon-cuowu" ng-click="pagedata.changeshow=false"></i>
			<div class='fui-content' style="padding:0.5rem">
				<div class="tips tips-yellow">
						<i class="fa fa-bullhorn alert-link"></i> 商品订单已打包好,由平台配送员配送！
				</div>
				<div class="weui_cell weui_cell_switch">
					<div class="weui_cell_hd">需要指定配送员？</div>
					<div class="weui_cell_bd weui_cell_primary">
						<input class="weui_switch" type="checkbox" ng-value="ifelse(pagedata.post.need_setpeisong==1,true,false)" ng-click="toogle(pagedata.post,'need_setpeisong',[1,0])" value="false">
					</div>
				</div>
				<div class="weui_cell weui_cell_select ng-scope" ng-if="pagedata.post.need_setpeisong==1">
						<div class="weui_cell_hd">
							指定配送员
						</div>
						<div class="weui_cell_bd weui_cell_primary">
							<select class="weui_select ng-pristine ng-valid ng-empty ng-touched" ng-model="pagedata.post.paisong_id">
								<option ng-repeat="op in pagedata.peisongs" ng-selected="pagedata.post.paisong_id==op.mid" value="{{op.mid}}" class="ng-binding ng-scope">{{op.title}}</option>
							</select>
						</div>
				</div>
				<div class="weui_btn_area">
				 <a class="weui_btn weui_btn_primary" href="javascript:" id="showTooltips" ng-click="post(pagedata.post,'/worker_order/change/');pagedata.changeshow=false">提交</a>
				 </div>
			</div>
		</div>
	</div>
</div>
<div ng-if="pagedata.showbaobei" class="popup">
	<div class="popup-body">
		<div class="popup-bottom">
			<i class="closed icon icon-cuowu" ng-click="pagedata.showbaobei=false"></i>
			<div class='fui-content' style="padding:0.5rem">
				<div class="title bold">异常报备 / <small>Reported</small></div>
				<div class="tips tips-yellow">
						<i class="fa fa-bullhorn alert-link"></i> 请选择需要报备的异常问题，报备内容将同步顾客及总部，请如实上报！
				</div>
				<div class="weui_cells weui_cells_radio2" style="margin-top:0.2rem">
						<label class="weui_cell weui_check_label dashed">
							<div class="weui_cell_bd weui_cell_primary">
								<span style="float:left;width:100%"><i class="icon icon-map"></i> 顾客更改送货地址</span>
							</div>
							<div class="weui_cell_ft" href="javascript:;" ng-click="pagedata.post.baobeitype=1">
								<input type="radio" class="weui_check" name="radio1">
								<span class="weui_icon_checked"></span>
							</div>
						</label>
						<label class="weui_cell weui_check_label dashed">
							<div class="weui_cell_bd weui_cell_primary">
								<span style="float:left;width:100%"><i class="icon icon-phone"></i> 联系不上顾客</span>
							</div>
							<div class="weui_cell_ft" href="javascript:;" ng-click="pagedata.post.baobeitype=2">
								<input type="radio" class="weui_check" name="radio1">
								<span class="weui_icon_checked"></span>
							</div>
						</label>
						<label class="weui_cell weui_check_label dashed">
							<div class="weui_cell_bd weui_cell_primary">
								<span style="float:left;width:100%"><i class="icon icon-all"></i> 其他异常原因</span>
							</div>
							<div class="weui_cell_ft" href="javascript:;" ng-click="pagedata.post.baobeitype=3">
								<input type="radio" class="weui_check" name="radio1">
								<span class="weui_icon_checked"></span>
							</div>
						</label>
						<div ng-if="pagedata.post.baobeitype==3" class="weui_cells weui_cells_radio" style="margin-top:0.2rem;background:#f2f2f2;padding-right:0">
							<label class="weui_cell weui_check_label dashed">
								<div class="weui_cell_bd weui_cell_primary" style="padding:0.2rem">
									<span style="float:left;width:100%">送货地址超区且无法配送</span>
								</div>
								<div class="weui_cell_ft" href="javascript:;" ng-click="pagedata.post.othertype=1">
									<input type="radio" class="weui_check" name="radio2">
									<span class="weui_icon_checked"></span>
								</div>
							</label>
							<label class="weui_cell weui_check_label dashed">
								<div class="weui_cell_bd weui_cell_primary" style="padding:0.2rem">
									<span style="float:left;width:100%">顾客拒收货品</span>
								</div>
								<div class="weui_cell_ft" href="javascript:;" ng-click="pagedata.post.othertype=2">
									<input type="radio" class="weui_check" name="radio2">
									<span class="weui_icon_checked"></span>
								</div>
							</label>
							<label class="weui_cell weui_check_label dashed">
								<div class="weui_cell_bd weui_cell_primary" style="padding:0.2rem">
									<span style="float:left;width:100%">以上都不是</span>
								</div>
								<div class="weui_cell_ft" href="javascript:;" ng-click="pagedata.post.othertype=3">
									<input type="radio" class="weui_check" name="radio2">
									<span class="weui_icon_checked"></span>
								</div>
							</label>
						</div>
				</div>
				<div class="weui_btn_area">
				 <a class="weui_btn weui_btn_primary" href="javascript:" id="showTooltips" ng-click="post(pagedata.post,'/worker_order/baobei/');pagedata.showbaobei=false">提交</a>
				 </div>
			</div>
		</div>
	</div>
</div>
<div ng-if="pagedata.showpayewm" class="popup">
	<div class="popup-body">
		<div class="popup-center">
			<i class="closed icon icon-cuowu" ng-click="pagedata.showpayewm=false"></i>
			<div class="c" style="padding-top:2rem" id="show_verify_ewm"></div>
			<div class="c" style="padding-bottom:2rem">客户扫二维码补差价</div>
		</div>
	</div>
</div>
<div class="fe-floatright-bottom" style="bottom:5rem">
<a ng-if="pagedata.isopenvoice!=1" ng-click="pagedata.isopenvoice=1;pagedata.openvoice(true)" href="javascript:;"><i class="icon icon-nolingsheng0"></i></a>
<a ng-if="pagedata.isopenvoice==1" ng-click="pagedata.isopenvoice=0;pagedata.openvoice(false)" href="javascript:;"><i class="icon icon-lingsheng0"></i></a> 
</div>
<audio id="openvoice" controls preload="auto" style="display:none;">
	<source src="../core/resource/images/neworder.mp3"></source>
</audio>
<script type="text/javascript">
//scope.pagedata.status = -1;  //状态标记
scope.pagedata.show_ewn=function(id){
	var url=scope.tool.custom_url('jy_weishop/order.list//gopayaddpriceid='+id,true);
	scope.tool.qr(url,'show_verify_ewm',150);
}
scope.pagedata.openLocation=function(item){
	var pcdaddress= item.pcd?item.pcd.province+item.pcd.city+item.pcd.district+item.pcd.street:'';
	var post={
		'address':pcdaddress+item.address,
		'city':item.pcd?item.pcd.city:''
	}
	scope.tool.get_latlng(post,function(res){
		var lat_lng = res.location
		var address_components = res.address_components
		wx.openLocation({
			latitude: lat_lng.lat, // 纬度，浮点数，范围为90 ~ -90
			longitude: lat_lng.lng, // 经度，浮点数，范围为180 ~ -180。
			name: pcdaddress, // 位置名
			address: item.address, // 地址详情说明
			scale: 20, // 地图缩放级别,整形值,范围从1~28。默认为最大
			infoUrl: '', // 在查看位置界面底部显示的超链接,可点击跳转
			success:function(){
				//alert(1111);
			},
			fail:function(res){
				scope.message('导航异常，可能是权限问题：'+res.errMsg);
			}
		});
	});
	
}
</script>
<script>
scope.tool.get_list('jy_peimilk/worker_order/list/status='+scope.pagedata.status,true);
scope.pagedata.scroll_bottom=function(){
	scope.tool.get_list('jy_peimilk/worker_order/list/status='+scope.pagedata.status);
}
scope.pagedata.openvoice=function(type){
	var voicetime = {};
    var openvoice;
	if(type || scope.pagedata.isopenvoice==1){
		 openvoice = setInterval(() => {
			if(scope.pagedata.isopenvoice!=1){
				clearInterval(openvoice);
				return false;
			}
			scope.get('jy_peimilk/index/getnew/',function(res){
						console.log('openvoice');console.log(res);
						if(res!='none'){
							if(!voicetime[res.id]){
								voicetime[res.id]=1;
								$("#openvoice")[0].play();
							}
							if(scope.pagedata.status==2){
								scope.tool.get_list('jy_peimilk/worker_order/list/status='+scope.pagedata.status,true);
							}
						}
			});
		}, 5000);
	}else{
		scope.get('jy_peimilk/index/setopenvoice/isopenvoice=0',function(res){});
	}
}
scope.pagedata.openvoice();
</script>